%%{init: {'themeVariables': { 'fontSize': '12px'}}}%%
graph TD
    classDef path fill:#eee,stroke:#000,color:#000
    classDef plan fill:#fff,stroke-width:1px,color:#000
    classDef itemplan fill:#fff,stroke-width:2px,color:#000
    classDef unbatchedplan fill:#dff,stroke-width:1px,color:#000
    classDef sideeffectplan fill:#fcc,stroke-width:2px,color:#000
    classDef bucket fill:#f6f6f6,color:#000,stroke-width:2px,text-align:left

    subgraph "Buckets for queries/connections/order"
    Bucket0("Bucket 0 (root)<br /><br />1: PgSelectInlineApply[50]<br />ᐳ: 11, 12, 54, 55, 13, 17<br />2: PgSelect[10], PgSelect[22]<br />ᐳ: Access[32], Access[51]<br />3: Connection[14], PgSelectRows[24]<br />ᐳ: 23, 25, 26<br />4: ConnectionItems[18]<br />ᐳ: 31, 33, 34, 35"):::bucket
    Bucket1("Bucket 1 (nullableBoundary)<br />Deps: 14, 32, 18, 51, 26, 33, 35<br /><br />ROOT Connectionᐸ10ᐳ[14]"):::bucket
    Bucket3("Bucket 3 (listItem)<br />Deps: 32, 51<br /><br />ROOT __Item{3}ᐸ18ᐳ[27]"):::bucket
    Bucket4("Bucket 4 (nullableBoundary)<br />Deps: 27, 28, 51, 37<br /><br />ROOT Edge{3}[28]"):::bucket
    Bucket5("Bucket 5 (nullableBoundary)<br />Deps: 38, 51<br /><br />ROOT PgSelectSingle{4}ᐸmessagesᐳ[38]<br />1: <br />ᐳ: 39, 52, 53<br />2: PgSelectRows[46]<br />ᐳ: First[45], PgSelectSingle[47]"):::bucket
    Bucket6("Bucket 6 (nullableBoundary)<br />Deps: 47<br /><br />ROOT PgSelectSingle{5}ᐸusersᐳ[47]"):::bucket
    end
    Bucket0 --> Bucket1
    Bucket1 --> Bucket3
    Bucket3 --> Bucket4
    Bucket4 --> Bucket5
    Bucket5 --> Bucket6

    %% plan dependencies
    PgSelect10[["PgSelect[10∈0] ➊<br />ᐸmessages+1ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[55]"]]:::plan
    Object13{{"Object[13∈0] ➊<br />ᐸ{pgSettings,withPgClient}ᐳ"}}:::plan
    Lambda17{{"Lambda[17∈0] ➊<br />ᐸincludeArchivedConditionᐳ<br />More deps:<br />- Constantᐸ[ undefined, 'INHERIT' ]ᐳ[54]"}}:::plan
    PgSelectInlineApply50["PgSelectInlineApply[50∈0] ➊"]:::plan
    Object13 & Lambda17 & PgSelectInlineApply50 --> PgSelect10
    PgSelect22[["PgSelect[22∈0] ➊<br />ᐸmessages(aggregate)ᐳ<br />More deps:<br />- Constantᐸ5ᐳ[55]"]]:::plan
    Object13 & Lambda17 --> PgSelect22
    Access11{{"Access[11∈0] ➊<br />ᐸ2.pgSettingsᐳ"}}:::plan
    Access12{{"Access[12∈0] ➊<br />ᐸ2.withPgClientᐳ"}}:::plan
    Access11 & Access12 --> Object13
    Connection14[["Connection[14∈0] ➊<br />ᐸ10ᐳ<br />Dependents: 4<br />More deps:<br />- Constantᐸ5ᐳ[55]"]]:::plan
    PgSelect10 --> Connection14
    __Value2["__Value[2∈0] ➊<br />ᐸcontextᐳ"]:::plan
    __Value2 --> Access11
    __Value2 --> Access12
    ConnectionItems18[["ConnectionItems[18∈0] ➊<br />Dependents: 3<br />More deps:<br />- Connection[14]"]]:::plan
    First23{{"First[23∈0] ➊"}}:::plan
    PgSelectRows24[["PgSelectRows[24∈0] ➊"]]:::plan
    PgSelectRows24 --> First23
    PgSelect22 --> PgSelectRows24
    PgSelectSingle25{{"PgSelectSingle[25∈0] ➊<br />ᐸmessagesᐳ"}}:::plan
    First23 --> PgSelectSingle25
    First31{{"First[31∈0] ➊<br />More deps:<br />- ConnectionItems[18]"}}:::plan
    Access32{{"Access[32∈0] ➊<br />ᐸ10.cursorDetailsᐳ<br />Dependents: 3"}}:::plan
    PgSelect10 --> Access32
    Last34{{"Last[34∈0] ➊<br />More deps:<br />- ConnectionItems[18]"}}:::plan
    Access51{{"Access[51∈0] ➊<br />ᐸ10.m.joinDetailsFor41ᐳ"}}:::plan
    PgSelect10 --> Access51
    PageInfo21{{"PageInfo[21∈1] ➊<br />More deps:<br />- Connection[14]"}}:::plan
    Access29{{"Access[29∈1] ➊<br />ᐸ14.hasNextPageᐳ<br />More deps:<br />- Connection[14]"}}:::plan
    Access30{{"Access[30∈1] ➊<br />ᐸ14.hasPreviousPageᐳ<br />More deps:<br />- Connection[14]"}}:::plan
    Edge28{{"Edge[28∈3]"}}:::plan
    __Item27[/"__Item[27∈3]<br />ᐸ18ᐳ<br />More deps:<br />- ConnectionItems[18]"\]:::itemplan
    PgCursor37{{"PgCursor[37∈3]<br />More deps:<br />- Access[32]"}}:::plan
    __Item27 & PgCursor37 --> Edge28
    __Item27 --> PgCursor37
    PgSelectSingle38{{"PgSelectSingle[38∈4]<br />ᐸmessagesᐳ"}}:::plan
    __Item27 --> PgSelectSingle38
    List52{{"List[52∈5]<br />ᐸ51,38ᐳ"}}:::plan
    Access51 & PgSelectSingle38 --> List52
    PgClassExpression39{{"PgClassExpression[39∈5]<br />ᐸ__messages__.”body”ᐳ"}}:::plan
    PgSelectSingle38 --> PgClassExpression39
    First45{{"First[45∈5]"}}:::plan
    PgSelectRows46[["PgSelectRows[46∈5]"]]:::plan
    PgSelectRows46 --> First45
    Lambda53{{"Lambda[53∈5]<br />ᐸpgInlineViaJoinTransformᐳ"}}:::plan
    Lambda53 --> PgSelectRows46
    PgSelectSingle47{{"PgSelectSingle[47∈5]<br />ᐸusersᐳ"}}:::plan
    First45 --> PgSelectSingle47
    List52 --> Lambda53
    PgClassExpression48{{"PgClassExpression[48∈6]<br />ᐸ__users__.”username”ᐳ"}}:::plan
    PgSelectSingle47 --> PgClassExpression48
    PgClassExpression49{{"PgClassExpression[49∈6]<br />ᐸ__users__....vatar_url”ᐳ"}}:::plan
    PgClassExpression48 o--o PgClassExpression49

    %% define steps
    classDef bucket0 stroke:#696969
    class Bucket0,__Value2,PgSelect10,Access11,Access12,Object13,Connection14,Lambda17,ConnectionItems18,PgSelect22,First23,PgSelectRows24,PgSelectSingle25,First31,Access32,Last34,PgSelectInlineApply50,Access51 bucket0
    classDef bucket1 stroke:#00bfff
    class Bucket1,PageInfo21,Access29,Access30 bucket1
    classDef bucket3 stroke:#ffa500
    class Bucket3,__Item27,Edge28,PgCursor37 bucket3
    classDef bucket4 stroke:#0000ff
    class Bucket4,PgSelectSingle38 bucket4
    classDef bucket5 stroke:#7fff00
    class Bucket5,PgClassExpression39,First45,PgSelectRows46,PgSelectSingle47,List52,Lambda53 bucket5
    classDef bucket6 stroke:#ff1493
    class Bucket6,PgClassExpression48,PgClassExpression49 bucket6

